
<template>
	<div class="index">

		<div class="center">
			<left></left>
			<div class="right">
          <top></top>
          <div class="hei10"></div>
          <div class="where" style="background: #fff; padding: 10px 30px; font-size: 14px; color: #595959;">当前位置：分销后台><router-link to="/shopdetail" style="color: #409eff;">商品详情</router-link></div>
          <div class="hei10"></div>
<div class="addpro">
					<div class="step" v-loading = 'loading'>
						<div class="tilte">商品页信息</div>
						<div class="con">
							<div class="shop-title">{{shopform.title}}商品详情 <span class="green" v-if="shopform.status == 100">上架中</span><span class="red" v-if="shopform.status != 100">已下架</span></div>
							<div class="shop-time">
                <template v-if="!shopform.operationUser">
								发布人：<span>{{shopform.publisher}}</span>
                </template>
                <template v-if="shopform.operationUser">
                操作人：<span>{{shopform.operationUser}}</span>
                </template>
								最后修改日期：<span>{{shopform.updated_at}}</span>
								产品渠道：<span>{{shopform.parent_title}}</span>
                <template v-if="versionlist.length > 0">
                历史版本：<el-select v-model="version" placeholder="请选择历史版本" @change="changeVersion" clearable>
                            <el-option v-for="item in versionlist" :key="item.id" :label="item.log_title" :value="item.id"></el-option>
                        </el-select>
                </template>
							</div>
							<el-form ref="form" :rules="rules" @submit.native.prevent :model="shopform" label-width="180px">

								<el-form-item label="商品名称:">
									{{shopform.title}}
								</el-form-item>
								<el-form-item label="商家编码（抓单标识）:" >
									{{randomnum}}
								</el-form-item>
                                <!-- <el-form-item label="京东特有(必须三位):" style="width: 450px;">
                                    {{jingdongrandom}}
                                </el-form-item> -->
								<el-form-item label="卖点" >
									{{shopform.selling_point}}
								</el-form-item>
								<el-form-item label="结算要求:">
									{{shopform.commission_rule}}
								</el-form-item>
								<el-form-item label="销售页上传照片:">
									<div v-if="shopform.is_need_photo == 0"> 无需照片</div>
									<div v-if="shopform.is_need_photo == 1"> 需要照片</div>
								</el-form-item>
								<div class="flex">
									<el-form-item label="产品主图:" >
										<div class="eaea">
											<img v-if="shopform.image1" :src="shopform.image1" class="avatar">
										</div>

									</el-form-item>
								</div>
								<el-form-item label="产品详情:">
									<!-- <div id="editor">

									</div> -->
									<div class="eaea" v-html="shopform.description"></div>
								</el-form-item>



                <el-form-item label="其他备注:">
                	<!-- <div id="editor">

                	</div> -->
                	<div class="eaea" v-html="shopform.pdd_description"></div>
                </el-form-item>
                <div  v-if="shop_id != 50481 && shop_id != 304676">
                  <el-form-item label="修改摘要:">
                    {{abstract}}
                  </el-form-item>

                  <el-form-item label="月租:" v-if="shopform.details">
                  	{{shopform.details.yuezu}}
                  </el-form-item>
                  <el-form-item label="流量:" v-if="shopform.details">
                    {{shopform.details.liuliang}}
                  </el-form-item>
                  <el-form-item label="语音通话:" v-if="shopform.details">
                    {{shopform.details.yuyin}}
                  </el-form-item>
                  <el-form-item label="其他权益:" v-if="shopform.details">
                    {{shopform.details.quanyi}}
                  </el-form-item>
                  <el-form-item label="套餐优惠期:" v-if="shopform.details">
                    {{shopform.details.taocan}}
                  </el-form-item>
                </div>


                <div >
                    <div style="padding: 20px 0; font-size: 16px; font-weight: bold;">套餐详情</div>
                  	<el-form-item label="归属地：">
                      <div class="kflex">
                        <div v-for="(item,index) in shopform.guishudi" key="index" style="margin-right: 30px;">
                          {{item.province}}-{{item.city}}
                        </div>
                      </div>


                  	</el-form-item>
                  	<el-form-item label="月租：">
                  		{{shopform.yuezu}}
                  	</el-form-item>
                  	<el-form-item label="流量：">
                  		{{shopform.liuliang}}
                  	</el-form-item>
                  	<el-form-item label="语音通话：">
                  		{{shopform.yuyin}}
                  	</el-form-item>
                  	<el-form-item label="套餐优惠期:">
                      <div class="l2 kflexc zidong">
                        {{shopform.yuezu_time}}个月,
                        <div>优惠期起始时间：</div>
                        <div>自激活起</div>
                        <span v-if="shopform.yuezu_type == 1">当月</span>
                        <span v-if="shopform.yuezu_type == 2">次月</span>
                        <span v-if="shopform.yuezu_type == 3">第三月</span>
                        <div>开始</div>
                      </div>
                  	</el-form-item>
                    <el-form-item label="套餐详细信息:" style="margin: 20px 0;">
                    	<!-- <div id="editor">

                    	</div> -->
                    	<div class="eaea" v-html="shopform.package_text"></div>
                    </el-form-item>
                    <!-- <el-form-item label="佣金结算周期:">
                      <div class="l2 kflexc zidong">
                        {{shopform.yongjin_time}}个月,
                        <div>结算起始时间：</div>
                        <div>自激活起</div>
                        <span v-if="shopform.yuezu_type == 1">当月</span>
                        <span v-if="shopform.yuezu_type == 2">次月</span>
                        <span v-if="shopform.yuezu_type == 3">第三月</span>
                        <div >开始</div>
                      </div>
                    </el-form-item> -->
                    <!-- <el-form-item label="返费周期:">
                      <div class="l2 kflexc zidong">
                        {{shopform.fanli_time}}个月,
                        <div>返利起始时间：</div>
                        <div>自激活起</div>
                        <span v-if="shopform.yuezu_type == 1">当月</span>
                        <span v-if="shopform.yuezu_type == 2">次月</span>
                        <span v-if="shopform.yuezu_type == 3">第三月</span>
                        <div>开始</div>
                      </div>
                    </el-form-item> -->
                  </div>
                  <!-- //到这里 -->

							</el-form>
						</div>
					</div>


				</div>
			</div>
		</div>
         <el-dialog title="自定义抓单ID" :visible.sync="randomlog" width="400px">
        	  <div class="randomdiv">
                  <el-input v-model="randomvalue" @input="randomnumwrite" placeholder="自定义抓单ID"></el-input>
              </div>
        	  <span slot="footer" class="dialog-footer">
        		<el-button @click="randomlog = false">取 消</el-button>
        		<el-button type="primary" @click="randomgo" :disabled="randomone">确 定</el-button>
        	  </span>
        </el-dialog>
		<el-dialog title="自定义产品类型" :visible.sync="taglog" width="400px">
			  <div class="protag">
				  <el-tag :key="item.id" v-for="item in typelist" closable :disable-transitions="false" @close="handleClose(item.name)">{{item.name}}</el-tag>
					<el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
					</el-input>
					<el-button v-else class="button-new-tag" size="small" @click="showInput">输入自定义名称</el-button>
			  </div>
			  <span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
			  </span>
		</el-dialog>
		<!-- <foot></foot> -->
	</div>
</template>

<script>
	import { provinceAndCityDataPlus, CodeToText, TextToCode } from 'element-china-area-data'
	import UploadExcelComponent from "@/components/UploadExcel/index.vue";
	import E from 'wangeditor'
	import axios from 'axios'
	import top from '@/components/top.vue'
	import left from '@/components/left.vue'
	import foot from '@/components/foot.vue'
	export default{
		components: {
			"left": left,
			"top": top,
			"foot": foot,
			UploadExcelComponent
		},
		name: 'shopdetail',
		data(){
			return{
				taglog:false,
				taglist:['类型1','类型2'],
				inputVisible: false,
				inputValue: '',

				mingan:{
					city:"",
					citys:[],
					fixcitys:[]
				},
				randomnum:"",
                jingdongrandom:"",
				search:"",
				msg:"hello",
				log:false,
				loading:true,

				typelist:{},
				citylist:provinceAndCityDataPlus,

				form:{
					produce_address:"",
					operator:"",
					name:"",
					sku:"",
					plan_type_id:"",
					province:"",
					city:[],
					citys:[],
					real_name_type:'0',
					produce_remark:"",
					status:"",
					comname:"",
					min_age:18,
					max_purchase:5,

					haochinum:1,
					haochival:1,

					address_province:"",
					address_city:"",
					address_district:"",
					commission_rule:""
				},
				shopform:{
					product_id:"",
					title:"",
					status:"",
					parent_id:"",
					selling_point:"",
					commission_rule:"",
					is_need_photo:"0",
					description:"",
					image1:"",
					imageUrl: '',
					imageUrl2: '',
          details:{
            yuezu:"",
            liuliang:"",
            yuyin:"",
            quanyi:"",
            taocan:""
          }
				},
				moneyform:{
					order_page_id:"",
					visible:'1',
					commission:0,
					child_shop_ids:"",
					dislist:"",
					money:"",
					list:""
				},
                rules: {
                  operator: [{ required: true, message: '必选', trigger: 'change' }],
				  name: [{ required: true, message: '必填', trigger: 'blur' }],
				  title: [{ required: true, message: '必填', trigger: 'blur' }],
				  proid: [{ required: true, message: '必填', trigger: 'blur' }],
                  sku: [{ required: true, message: '必填', trigger: 'blur' }],
                  city: [{ required: true, message: '请选择活动区域', trigger: 'change' }],
                  real_name_type: [{ required: true, message: '请输入', trigger: 'change' }],
                  randomnum: [{ required: true, message: '请输入抓单码', trigger: 'change' }],
                  // title: [{ required: true, message: '必填', trigger: 'change' }],
                  is_need_photo: [{ required: true, message: '必选', trigger: 'change' }],
                  img: [{ required: true, message: '必选', trigger: 'change' }],
                  edit: [{ required: true, message: '必填', trigger: 'change' }],
                  visible: [{ required: true, message: '必选', trigger: 'change' }],
                  commission: [{ required: true, message: '必选', trigger: 'change' }],
                },
				kejian:false,
				sub1:true,
				sub2:true,
				sub3:true,
                sub4:true,
				showmoney:false,
				sanlist:[
					// {name:"中国联通",id:10000},
					// {name:"中国移动",id:10086},
					// {name:"中国电信",id:10010},
					{name:"中国广电",id:10099}
				],
                randomvalue:"",
                randomone:false,
                randomlog:false,

                shop_id:"",
                abstract:"",
				statusshop:false,

				prolists:[],


				basis:0,
				basislog:false,
				proid:"",
				shopid:"",
				shoplists:{},
				basisshop:"",
				semod:1,


        version: '',
        versionlist: []
			}
		},
		created() {
			//获取分销商
			this.getdislist()
			//获取类型
			this.getproductstype();
			this.getpros();
			this.getshops()
            axios.get('/api/gth/user/shop')
                .then(response => {
                    if(response.data.msg.code == 0){
                        this.shop_id = response.data.data.shop_id
                    }else{
                        if(response.data.msg.code == 50401){that.$router.push({ path: "/login" }); return false}
                        that.$message.error(response.data.msg.info);
                    }
                })
		},
		mounted() {
			var that = this
			var editor = new E('#editor');
			editor.customConfig.uploadImgServer = '/upload'
			editor.customConfig.showLinkImg = false
			editor.customConfig.onchange = function (html) {
				that.shopform.description = html
			}
			editor.customConfig.customUploadImg = function (files, insert) {
				var formData = new FormData();
				formData.append("pic",files[0]);
				axios.post('/api/plan-market/order-page/upload-pic',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							insert(response.data.data)

						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			}
			editor.create();

			//获取商品详情后追加内容
			var that = this;
			axios.get('/api/plan-market/order-page?order_page_id='+this.$route.query.id)
				.then(response => {
					if(response.data.msg.code == 0){
						var arr = ""
						for(var i in response.data.data.selling_point){
							arr = arr + response.data.data.selling_point[i]
						}
						response.data.data.selling_point = arr
						if( response.data.data.is_need_photo == "0"){ response.data.data.is_need_photo = "0"}
						if( response.data.data.is_need_photo == "1"){ response.data.data.is_need_photo = "1"}
            that.versionlist = response.data.data.history_logs || []
						that.randomnum = response.data.data.fetch_code
                        that.jingdongrandom = response.data.data.fetch_code2
						that.shopform = response.data.data
                        if(response.data.data.status == 0){
                            that.statusshop = false
                        }else{
                            that.statusshop = true
                        }
						editor.txt.html(that.shopform.description)

						if(that.shopform.parent_id == 0){
							that.semod = '1'
							that.proid = that.shopform.product_id
						}else{
							that.semod = '2'
							that.shopid = that.shopform.parent_id
						}
if(that.shopform.details){
              that.shopform.details = JSON.parse(that.shopform.details)
            }else{
              that.shopform.details={
                yuezu:"",
                liuliang:"",
                yuyin:"",
                quanyi:"",
                taocan:""
              }
            }
						that.loading = false

					}else{
						that.$message.error(response.data.msg.info);
					}
				})


		},
		methods:{
      //选择版本
      changeVersion(id){
        let item = ""
        if(id){
          this.versionlist.forEach(item2=>{
            if(item2.id == id){
              item = item2
            }
          })
        }else{

        }

        var flag = ''
        this.loading = true
        if(item.id){
          flag = 2
        }
        else{
          flag = 1
        }
        var that = this
        axios.get('/api/plan-market/order-page?order_page_id='+this.$route.query.id+'&flag='+flag+'&log_id='+item.id+'&log_title='+item.log_title)
        	.then(response => {
        		if(response.data.msg.code == 0){
        			var arr = ""
        			for(var i in response.data.data.selling_point){
        				arr = arr + response.data.data.selling_point[i]
        			}
        			response.data.data.selling_point = arr
              console.log(response.data.data.selling_point);
        			if( response.data.data.is_need_photo == "0"){ response.data.data.is_need_photo = "0"}
        			if( response.data.data.is_need_photo == "1"){ response.data.data.is_need_photo = "1"}
        		  that.versionlist = response.data.data.history_logs
        			that.randomnum = response.data.data.fetch_code
        		              that.jingdongrandom = response.data.data.fetch_code2
        			that.shopform = response.data.data
        		              if(response.data.data.status == 0){
        		                  that.statusshop = false
        		              }else{
        		                  that.statusshop = true
        		              }
        			// editor.txt.html(that.shopform.description)

        			if(that.shopform.parent_id == 0){
        				that.semod = '1'
        				that.proid = that.shopform.product_id
        			}else{
        				that.semod = '2'
        				that.shopid = that.shopform.parent_id
        			}

        			that.loading = false

        		}else{
              that.$message.error(response.data.msg.info);
            }
        })

      },
			//更换基础产品
			// basisgo:function(){
			// 	this.loading = true
			// 	var that = this
			// 	if( this.basis == 0){
			// 		axios.post('/api/plan-market/page/product/update',{product_id:this.proid,page_id:this.chooseid})
			// 			.then(response => {
			// 				if(response.data.msg.code == 0){
			// 					that.$message.success("修改成功");
			// 					that.getpro()
			// 					that.basislog = false
			// 				}else{
			// 					that.$message.error(response.data.msg.info);
			// 				}
			// 			})
			// 	}
			// 	if( this.basis == 1){
			// 		axios.post('/api/plan-market/page/product/update',{parent_page_id:this.shopid,page_id:this.chooseid})
			// 			.then(response => {
			// 				if(response.data.msg.code == 0){
			// 					that.$message.success("修改成功");
			// 					that.getpro()
			// 					that.basislog = false
			// 				}else{
			// 					that.$message.error(response.data.msg.info);
			// 				}
			// 			})
			// 	}
			// },
			// getallshop:function(){
			// 	if( this.basis == 0){this.getpros()}
			// 	if( this.basis == 1){this.getshops()}
			// },
			//获取全部基础产品
			getpros:function(){
				var that = this
			    axios.get('/api/gth/products/list?page_size=10000')
			        .then(response => {
			            if(response.data.msg.code == 0){
							that.prolists = response.data.data.data
							// for(var i in response.data.data.data){
							// 	var obj = {
							// 		name:response.data.data.data[i].name,
							// 		id:response.data.data.data[i].id
							// 	}
							// 	that.prolists.push(obj)
							// }
							// this.getshops()
			            }else{
			                that.$message.error(response.data.msg.info);
			            }
			        })

			},
			getshops:function(){
				//获取商品
				var that = this;
				axios.get('/api/gth/supplier/products?page_size=1000')
					.then(response => {
						if(response.data.msg.code == 0){
							that.shoplists = response.data.data.data
							// for(var i in response.data.data.data){
							// 	var obj = {
							// 		name:response.data.data.data[i].title,
							// 		id:response.data.data.data[i].id
							// 	}
							// 	that.prolists.push(obj)

							// }
						}else{
							if(response.data.msg.code == 50401){that.$router.push({ path: "/login" }); return false}
							that.$message.error(response.data.msg.info);
						}
					})
			},
			 //自定义抓单码唯一性
			randomnumwrite:function(){
			    var that = this
			    axios.get('/api/plan-market/order-page/fetch-code/isexist?fetch_code='+this.randomvalue)
			        .then(response => {
			            if(response.data.msg.code == 0){
			                that.randomone = false
			            }else{
			                that.randomone = true
			            }
			        })
			},
			//自定义抓单码点击确认
			randomgo:function(){
			    this.randomnum = this.randomvalue
			    this.randomlog = false
			},
			//获取产品详情
			getprodetail:function(){
				var that = this;
				axios.get('/api/plan-market/product?product_id='+this.$route.query.productid)
					.then(response => {
						if(response.data.msg.code == 0){
							this.form = response.data.data

							if( this.form.real_name_type == 0){ this.form.real_name_type="0"}
							if( this.form.real_name_type == 1){ this.form.real_name_type="1"}

							this.mingan.citys = this.form.warn_province
							this.mingan.fixcitys = this.form.warn_city



							// var city = []
							// if(this.form.province != ""){
							// 	city.push(TextToCode[this.form.province].code)
							// }
							// if(this.form.city != ""){
							// 	city.push(TextToCode[this.form.province][this.form.city].code)
							// }
							// this.form.citys = city


						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//获取商品品详情
			getshopdetail:function(){
				var that = this;
				axios.get('/api/plan-market/order-page?order_page_id='+this.$route.query.id)
					.then(response => {
						if(response.data.msg.code == 0){
							var arr = ""
							for(var i in response.data.data.selling_point){
								arr = arr + response.data.data.selling_point[i]
							}
							response.data.data.selling_point = arr

							if( response.data.data.is_need_photo == "0"){ response.data.data.is_need_photo = "0"}
							if( response.data.data.is_need_photo == "1"){ response.data.data.is_need_photo = "1"}
							that.randomnum = response.data.data.fetch_code
							that.shopform = response.data.data

						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},


			//修改佣金时执行全部佣金赋值并保存后重新获取一下列表和佣金
			fixallmoney:function(){
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id",this.moneyform.order_page_id);
				formData.append("visible",this.moneyform.visible);
				formData.append("commission",this.moneyform.commission);
				formData.append("child_shop_ids",this.moneyform.child_shop_ids);

				axios.post('/api/gth/order-page/visible',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							that.getmoneylist();
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//个性化编辑佣金
			fixmoney:function(i,id){
				this.$prompt('请输入金额', '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				}).then(response => {
					var that = this;
					var formData = new FormData();
					formData.append("order_page_id",that.moneyform.order_page_id);
					formData.append("child_shop_id",id);
					formData.append("commission",response.value);

					axios.post('/api/plan-market/order-page/commissions/update',formData)
						.then(response => {
							if(response.data.msg.code == 0){
								this.getmoneylist();
								that.$message({
								  message: '保存成功！',
								  type: 'success'
								});
							}else{
								that.$message.error(response.data.msg.info);
							}
						})
				})
			},
			//获取分销商和佣金
			getmoneylist:function(){
				var that = this;
				axios.get('/api/plan-market/order-page/commissions?order_page_id='+that.moneyform.order_page_id)
					.then(response => {
						if(response.data.msg.code == 0){
							that.moneyform.list = response.data.data.data
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},

			chakan:function(){
				console.log(this.moneyform.child_shop_ids)
			},
			//产品名验证唯一性
			nijiushiwodeweiyi1:function(){
				var that = this;
				axios.get('/api/plan-market/product/name/isexist?name='+that.form.name)
					.then(response => {
						if(response.data.msg.code == 0){
							this.sub1 = true
						}else{
							this.sub1 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//产品编号验证唯一性
			nijiushiwodeweiyi2:function(){
				var that = this;
				axios.get('/api/plan-market/product/sku/isexist?sku='+this.form.sku)
					.then(response => {
						if(response.data.msg.code == 0){
							this.sub2 = true
						}else{
							this.sub2 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//商品名验证唯一性
			nijiushiwodeweiyi3:function(){
				var that = this;
				axios.get('/api/plan-market/order-page/name/isexist?title='+this.shopform.title)
					.then(response => {
						if(response.data.msg.code == 0){
							this.sub3 = true
						}else{
							this.sub3 = false
							that.$message.error(response.data.msg.info);
						}
					})
			},
            //京东唯一性
            nijiushiwodeweiyi4:function(){
				this.jingdongrandom = this.jingdongrandom.trim()
                if(this.jingdongrandom == ""){
                    this.sub4 = true
                }else{
                   var that = this;
                   axios.get('/api/plan-market/order-page/fetch-code?fetch_code2='+this.jingdongrandom)
                   	.then(response => {
                   		if(response.data.msg.code == 0){
                   			this.sub4 = true
                   		}else{
                   			this.sub4 = false
                   			that.$message.error(response.data.msg.info);
                   		}
                   	})
                }

            },
			//身份证审核
			cardid:function(){
				this.moneyform.child_shop_ids = "";
				if(this.moneyform.visible == 3 || this.moneyform.visible == 4){this.kejian = true}
				if(this.moneyform.visible == 1 || this.moneyform.visible == 2){this.kejian = false}
			},
			//获取全部分销商
			getdislist:function(){
				var that = this;
				axios.get('/api/gth/partner/list?page_size=1000')
					.then(response => {
						if(response.data.msg.code == 0){
							that.moneyform.dislist = response.data.data.data
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//保存产品
			productsave:function(){
				//发布还是仅保存

				console.log(this.mingan.citys)
				if(this.form.address_province == undefined){
					this.form.address_province = this.form.province
					this.form.address_city = this.form.city
				}

				var that = this;
				var formData = {
					product_id:this.$route.query.productid,
					name:this.form.name,
					sku:this.form.sku,
					operator:this.form.operator,
					plan_type_id:this.form.plan_type_id,
					province:this.form.address_province,
					city:this.form.address_city,
					real_name_type:this.form.real_name_type,
					produce_remark:this.form.produce_remark,
					max_purchase:this.form.max_purchase,
					min_age:this.form.max_purchase,
					// status:this.form.status,
					produce_address:this.form.produce_address,
					commission_rule:this.form.commission_rule,
					warn_province:this.mingan.citys,
					warn_city:this.mingan.fixcitys,
                    abstract:this.abstract
				}
				axios.post('/api/plan-market/product',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							that.shopform.product_id = response.data.data.id
							//成功获取到产品id后执行保存商品
							that.shopsave();

						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//保存商品
			shopsave:function(){



                if(this.sub4 == false){
                	return false
                }
                if(this.jingdongrandom == "" || this.jingdongrandom == null){

                }else{
                    if(this.jingdongrandom.length != 3 ){
                        this.$message.error("京东抓单码必须三位或者不填写");
                        return false
                    }
                }
				var that = this;
				// if(this.basis == 0){
				// 	product_id:this.proid
				// 	page_id:this.chooseid
				// 	parent_page_id:this.shopid
				// 	page_id:this.chooseid
				// }

				var formData = {
					order_page_id:this.$route.query.id,
					title:this.shopform.title,
					selling_point:this.shopform.selling_point,
					commission_rule:this.shopform.commission_rule,
					is_need_photo:this.shopform.is_need_photo,
					description:this.shopform.description,
					image1:this.shopform.image1,
					fetch_code:this.randomnum,
					status:this.shopform.status,
                    fetch_code2:this.jingdongrandom,
                    abstract:this.abstract
				}
				if(this.semod == 1){
					formData['product_id'] = this.proid
				}else{
					formData['parent_id'] = this.shopid
				}
				axios.post('/api/plan-market/order-page',formData)
					.then(response => {
						if(response.data.msg.code == 0){
                            //下架商品
                            if(that.shopform.status == 0){
                                that.$message({
                                  message: '修改成功！',
                                  type: 'success'
                                });
                                that.$router.push({
                                    path: '/productionDelivery/productionDeliverysale'
                                })
                            }else{
                               //上架商品
                               if( this.shop_id == 50481 || this.shop_id == 304676){
                                    if(this.statusshop == true){
                                        that.$message({
                                           message: '商品已提交审核！',
                                           type: 'success'
                                        });
                                        that.$router.push({
                                           path: '/productionDelivery'
                                        })
                                    }else{
                                        that.$message({
                                          message: '修改成功！',
                                          type: 'success'
                                        });
                                        that.$router.push({
                                            path: '/productionDelivery'
                                        })
                                    }

                               }else{
                                 that.$message({
                                   message: '修改成功！',
                                   type: 'success'
                                 });
                                 that.$router.push({
                                     path: '/productionDelivery'
                                 })
                               }
                            }

						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//绑定佣金分销商
			bangding:function(){
				var that = this;
				var formData = new FormData();
				formData.append("order_page_id",this.moneyform.order_page_id);
				formData.append("visible",this.moneyform.visible);
				formData.append("commission",this.moneyform.commission);
				formData.append("child_shop_ids",this.moneyform.child_shop_ids);

				axios.post('/api/gth/order-page/visible',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							console.log(that.form.status)
							if(that.form.status == 0){
							    that.$message({
							      message: '修改成功！',
							      type: 'success'
							    });
							    that.$router.push({
							        path: '/productionDelivery'
							    })
							}else{
							   if( this.shop_id == 50481 || this.shop_id == 304676){
							       that.$message({
							          message: '商品已提交审核！',
							          type: 'success'
							      });
							      that.$router.push({
							          path: '/productionDelivery'
							      })
							   }else{
							     that.$message({
							       message: '修改成功！',
							       type: 'success'
							     });
							     that.$router.push({
							         path: '/productionDelivery'
							     })
							   }
							}
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},

			//单个图片上传
			uploadok:function(file){
				var that = this;
				var formData = new FormData();
				formData.append("pic",file.raw);
				axios.post('/api/plan-market/order-page/upload-pic',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							that.shopform.image1 = response.data.data
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
			},
			//选择省市区
			changeaddress:function(v){
				this.form.address_province = CodeToText[v[0]],
				this.form.address_city = CodeToText[v[1]],
				console.log("选中的省市"+this.form.address_province+this.form.address_city)
			},
			//导入敏感地区
			exportData:function(data) {
				console.log(data)
				this.mingan.citys = []
				this.mingan.fixcitys = []
				for(var i = 0 ;i < data.results.length; i++){
					this.mingan.citys.push(data.results[i]['敏感地区'])
					if(data.results[i]['修改敏感地区'].indexOf(",") > -1){
						var arr = data.results[i]['修改敏感地区'].split(',')
					}
					else if(data.results[i]['修改敏感地区'].indexOf("，") > -1){
						var arr = data.results[i]['修改敏感地区'].split('，')
					}
					else{
						return false
						that.$message.error("数据出错了，请检查格式");
					}
					var obj = {}
					obj[arr[0]] = arr[1]
					this.mingan.fixcitys.push(obj)
				}
			},
			//获取产品类型
			getproductstype:function(){
				var that = this
				axios.get("/api/gth/plan-type")
				  .then(function(response) {
					  if(response.data.msg.code == 0){
					  	that.typelist = response.data.data
					  }else{
					  	that.$message.error(response.data.msg.info);
					  }

				  })
			},

			loggo:function(){
				console.log("a")
			},

			//自定义产品类型
			handleClose(tag) {
				this.taglist.splice(this.taglist.indexOf(tag), 1);
			},

			showInput() {
				this.inputVisible = true;
				this.$nextTick(_ => {
				  this.$refs.saveTagInput.$refs.input.focus();
				});
			},

			handleInputConfirm() {
				var that = this;
				var formData = new FormData();
				formData.append("name",this.inputValue);
				axios.post('/api/gth/plan-type/release',formData)
					.then(response => {
						if(response.data.msg.code == 0){
							that.getproductstype();
							that.$message({
							  message: '添加成功',
							  type: 'success'
							});
						}else{
							that.$message.error(response.data.msg.info);
						}
					})
				let inputValue = this.inputValue;
				if (inputValue) {
				  this.taglist.push(inputValue);
				}
				this.inputVisible = false;
				this.inputValue = '';
			}
		}

	}
</script>

<style lang="scss" scoped>

	.index{
    /deep/ .el-message-box__wrapper{ z-index: 20000 !important;}
		// #editor{
		//     .w-e-text-container{ z-index: 1999 !important;}
		//     .w-e-menu{ z-index: 1999 !important;}
		// }

		.loglist{
			display: flex; justify-content: space-between; margin-bottom: 30px;
			.log_title{ padding: 7px 10px;}
		}
		.listl{ height: 350px; overflow: auto;
			/deep/ .el-input__inner{ border: none; text-align: center}
		}
		.list{

			display: flex; text-align: center; color: #727272; line-height: 45px; border: 1px #EAEAEA solid; margin-top: -1px;
			.th{ flex: 1; background: #F9F9F9; font-size: 14px; }
			.td{ flex: 1; font-size: 14px; border-right:1px #EAEAEA solid; }
		}
		/deep/ .el-pagination{ text-align: right; margin: 20px 0}
		/deep/ .el-dialog__wrapper{ z-index: 19999 !important;}

		.protag{
			/deep/ .el-tag{ margin-right: 20px; margin-bottom: 20px;}
		}
		.addpro{
			 width: 1166px;
			/deep/ .el-steps{ width: 100%;  padding: 30px;}
			.step{ margin-bottom: 20px; background: #FFFFFF;
				.redbor{
					/deep/ .el-input__inner{border: 1px #EEF7FF solid;}
				}
				.tilte{ background: #F9F9F9; padding-left: 30px; line-height: 45px; font-size: 14px;
					span{ background: #B1E4FF; color: #FFFFFF; float: right; line-height: 15px; cursor: pointer; padding: 5px 0; display: block; width: 24px; text-align: center; margin-right: 20px; margin-top: 8px; border-radius: 14px;}
				}
				.w330{
					/deep/ .el-input__inner{ width: 330px !important;}
				}
				.w480{
					/deep/ .el-input__inner{ width: 480px !important;}
				}
				.con{ background: #FFFFFF; padding: 35px;
					.shop-title{ font-size: 18px; margin-bottom: 30px; color: #333;
						span{ font-size: 14px; margin-left: 40px;}
						.red{ color: #EEF7FF}
						.green{ color: green}
					}
					.eaea{ background: #EAEAEA; padding: 10px;}
					/deep/ .el-form-item{ margin-bottom: 0;}
					.shop-time{ font-size: 14px; color: #999; border-bottom: 3px #eaeaea solid; padding-bottom: 10px;
						span{ margin-right: 40px;}
					}
					.flex{ display: flex;}
					.ori{ background: #FBFBFB; padding: 20px 10px;
						/deep/ .el-input{ width: 300px;}
						/deep/ .el-form-item{ margin-bottom: 20px;}
						/deep/ .el-form-item__label{ width: 150px !important;}

						.wenhao2{color: #999; font-size: 14px;}
						.no{
							display: flex; align-items: center;
							#drop{
								/deep/ .el-button--primary{ background: #409EFF}
							}
							.nonum{ background: #409EFF; padding: 0px 10px; line-height: 35px; height: 35px; color: #FFFFFF; border-radius: 3px; display: block;}
							.el-button{ }
							span{ margin: 0 20px;}
						}

					}
				}
				.haochi{ padding: 30px;
					.el-select{ margin-left: 20px;}
				}
				.btm0 {
					.el-button{ margin-left: 20px;}
					.el-form-item{ margin-bottom: 0;}
				}
				.label200 .el-form-item__label{ width: 149px !important;}
				.avatar-uploader .el-upload {
					border: 1px dashed #d9d9d9;
					border-radius: 6px;
					cursor: pointer;
					position: relative;
					overflow: hidden;
				  }
				  /deep/ .avatar-uploader .el-upload:hover {
					border-color: #409EFF;
				  }
				  /deep/ .avatar-uploader-icon {
					font-size: 28px;
					color: #8c939d;
					width: 178px;
					height: 178px;
					line-height: 178px;
					text-align: center;
				  }
				  .avatar {
					width: 178px;
					height: 178px;
					display: block;
				  }
				.wenhao{ background: #B1E4FF; color: #FFFFFF; line-height: 15px; cursor: pointer; padding: 5px 11px; margin-left: 20px; text-align: center;  border-radius: 14px;}
			}

		}
	}
</style>
